import React from 'react'
import { useHistory } from 'react-router-dom'
// ================================================================ Image
import Bcimg from '@img/knowledge/bcimg.png'
// ================================================================ Plugin 
import Player from 'xgplayer'
// ================================================================ View 
const Index = ( ) => {
	const [ ajax, setAjax ] = React.useState({ data:{} })
	const history = useHistory( )
	/* --------------------------- 初始化 --------------------------- */
	React.useEffect(()=>{
		// window.$http.pull(setAjax,'case/info',{ param:{ spec_code:'101000100101'}, loading:true })
		const param = window.$fn.query()
		if(window.$fn.hasObject(param)){
			window.$http.pull(setAjax,'case/info',{ param, loading:true }).then(data=>{
				// history.replace('/?spec_code='+ data?.case?.spec_code)
				// if(data?.finished===0){
				// 	history.replace('/?spec_code='+ data?.case?.spec_code)
				// }
				new Player({
					id: 'vs',
					url: data?.kind?.video_path,
					fluid: true,
					videoInit:true,
					// autoplay:true,
				})
			})
		}else{
			history.replace('/index')
		}
	}, [ history ])
	/* --------------------------- 动态初始化 --------------------------- */
	React.useEffect(()=>{
		
	}, [ ])
	
	return (
		<>
			<div className='wh plr10 pb20' style={{background:`url(${Bcimg}) no-repeat top center/100%`, paddingTop:'42%'}}>
				<div className='bcf r8px h p10 oys' >
					<div className='fx'>
						<h5 className='b' style={{letterSpacing:'2px'}}>项目:</h5>
						<p className='b' style={{letterSpacing:'1px'}}>{ajax.data?.kind?.kind_name}</p>
					</div>
					<div className='fx g6 mt10'>
						<h5 className='' style={{letterSpacing:'2px'}}>条码号:</h5>
						<p style={{letterSpacing:'1px'}}>{ajax.data?.case?.spec_code}</p>
					</div>
					<div className='mt15'>
						<div id='vs'></div>
					</div>
					<h2 className='tc mtb20 b c0 16'>温馨提示</h2>
					<p className='bcb c0 p10 r5px lh22' style={{letterSpacing:'1px'}}>{ajax.data?.kind?.content}</p>
					<button className='cf bcm r8px h40 f15 mt20 w' onClick={()=>{
						history.push(`/?spec_code=${ajax.data?.case?.spec_code}`)
					}}>返回</button>
				</div>
			</div>
		</>
	)
}
export default Index